package com.yn.service.zy.model.dto;

import com.yn.common.model.zyorder.ZyOrder;
import com.yn.common.request.zyorder.ZyOrderRequest;
import com.yn.common.utils.BeanUtils;
import com.yn.common.utils.MoneyUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * @ClassName: ZyOrderDTO
 * @Description: 转运订单
 * @Author: ym
 * @Date: 2025/5/10 11:26
 **/
@Data
public class ZyOrderDTO {

    private Integer id;
    /** 出发地区编码 */
    @ApiModelProperty(value = "出发地区编码")
    private String startRegionCode;
    /** 目的地区编码 */
    @ApiModelProperty(value = "目的地区编码")
    private String endRegionCode;
    /** 出发地区名称 */
    @ApiModelProperty(value = "出发地区名称")
    private String startDestination;
    /** 目的地区名称 */
    @ApiModelProperty(value = "目的地区名称")
    private String endDestination;
    /** 出发地标 */
    @ApiModelProperty(value = "出发地标")
    private String startLocality;
    /** 出发地标 */
    @ApiModelProperty(value = "出发地标")
    private String endLocality;


    /** 乘车人数 */
    @ApiModelProperty(value = "乘车人数")
    private Integer ridingNumber;

    /** 用车时间 */
    @ApiModelProperty(value = "用车时间")
    private Date useCarDateTime;


    /** 乘坐人/下单人手机号码 */
    @ApiModelProperty(value = "乘坐人/下单人手机号码")
    private String userOrderPhone;
    /** 乘坐人/下单人姓名 */
    @ApiModelProperty(value = "乘坐人/下单人姓名")
    private String userOrderName;


    /** 出院诊断 */
    @ApiModelProperty(value = "出院诊断")
    private String dischargeDiagnosis;
    /** 转运类型 */
    @ApiModelProperty(value = "转运类型")
    private Integer transportType;


    /** 服务总费用(元) */
    @ApiModelProperty(value = "服务总费用(元)")
    private BigDecimal allServiceCost;


    /** 转运路程距离(米) */
    @ApiModelProperty(value = "转运路程距离(米)")
    private Integer transferDistance;
    /** 转运单价(元) */
    @ApiModelProperty(value = "转运单价(元)")
    private BigDecimal transferUnitPrice;


    /** 区域范围 */
    @ApiModelProperty(value = "区域范围")
    private Integer regionRange;
    /** 区域范围价格(元) */
    @ApiModelProperty(value = "区域范围价格(元)")
    private BigDecimal regionRangePrice;
    /** 转运距离需付金额 */
    @ApiModelProperty(value = "转运距离需付金额")
    private BigDecimal transferDistancePrice;


    /** 单子应付总金额(元) */
    @ApiModelProperty(value = "单子应付总金额(元)")
    private BigDecimal orderAllPrice;
    /** 实际付款金额 */
    @ApiModelProperty(value = "实际付款金额")
    private BigDecimal orderPayPrice;
    /** 使用积分 */
    @ApiModelProperty(value = "使用积分")
    private  Integer useIntegral;
    /** 优惠卷金额(元) */
    @ApiModelProperty(value = "优惠卷金额(元)")
    private BigDecimal couponPrice;


    /** 优惠卷id */
    @ApiModelProperty(value = "优惠卷id")
    private Integer couponId;
    /** 退款金额 */
    @ApiModelProperty(value = "退款金额")
    private BigDecimal orderReturnMoney;


    /** 退款状态 （0:待审核 1：退款中 2：退款完成 3：退款失败）*/
    @ApiModelProperty(value = "退款状态 （0:待审核 1：退款中 2：退款完成 3：退款失败）")
    private Integer orderReturnStatus;
    /** 支付状态 */
    @ApiModelProperty(value = "支付状态")
    private Boolean payStatus;


    /** 支付时间 */
    @ApiModelProperty(value = "支付时间")
    private Date payTime;
    /** 订单状态( 0：待付款 1:待接单,2:已接单,3:已取消,5:已送达，6:待评价 7已评价) */
    @ApiModelProperty(value = "订单状态( 0：待付款 1:待接单,2:已接单,3:已取消,5:已送达，6:待评价 7已评价)")
    private Integer orderStatus;


    /** 微信支付单号 */
    @ApiModelProperty(value = "微信支付单号")
    private String outTradeNo;
    /** 订单号 */
    @ApiModelProperty(value = "订单号")
    private String orderNo;
    /** 订单类型(1:普通订单 2:公益类型) */
    @ApiModelProperty(value = "订单类型(1:普通订单 2:公益类型)")
    private Integer orderType;
    /** 公益上传的材料 */
    @ApiModelProperty(value = "公益上传的材料")
    private String welfareMaterial;


    /** 下单人id */
    @ApiModelProperty(value = "下单人id")
    private Integer appUserId;


    /** 车长用户id */
    @ApiModelProperty(value = "车长用户id")
    private Integer carAppUserId;


    /** 乘坐车辆信息 */
    @ApiModelProperty(value = "乘坐车辆信息")
    private Integer carManageId;
    /** 评价内容 */
    @ApiModelProperty(value = "评价内容")
    private String orderEvaluation;
    /** 支付类型(支付类型：weixin-微信支付，yue-余额支付，offline-线下支付，alipay-支付包支付) */
    @ApiModelProperty(value = "支付类型(支付类型：weixin-微信支付，yue-余额支付，offline-线下支付，alipay-支付包支付)")
    private String payType;
    /** 支付渠道:weixinh5-微信H5支付，public-公众号支付，routine-小程序支付，weixinAppIos-微信appios支付，weixinAppAndroid-微信app安卓支付,alipay-支付包支付，appAliPay-App支付宝支付 */
    @ApiModelProperty(value = "支付渠道:weixinh5-微信H5支付，public-公众号支付，routine-小程序支付，weixinAppIos-微信appios支付，weixinAppAndroid-微信app安卓支付,alipay-支付包支付，appAliPay-App支付宝支付")
    private String payChannel;
    /** 支付平台 */
    @ApiModelProperty(value = "支付平台")
    private String payFrom;
    /** 下单时小程序的场景值 */
    @ApiModelProperty(value = "下单时小程序的场景值")
    private String scene;
    /** 支付渠道(0-微信公众号,1-微信小程序,2-H5,3-余额,4-微信AppIos,5-微信AppIos安卓,6-支付宝支付，7-支付宝app支付) */
    @ApiModelProperty(value = "支付渠道(0-微信公众号,1-微信小程序,2-H5,3-余额,4-微信AppIos,5-微信AppIos安卓,6-支付宝支付，7-支付宝app支付)")
    private Integer isChannel;
    /** 创建时间 */
    @ApiModelProperty(value = "创建时间")
    private Date createTime;


    public static ZyOrderDTO transform(ZyOrder zyOrder){
        if (Objects.isNull(zyOrder)){
            return null;
        }
        ZyOrderDTO zyOrderDTO = BeanUtils.copyProperties(zyOrder, ZyOrderDTO.class);

        if (Objects.nonNull(zyOrder.getAllServiceCost())){
            zyOrderDTO.setAllServiceCost(MoneyUtils.fen2yuan(zyOrder.getAllServiceCost()));
        }
        if (Objects.nonNull(zyOrder.getTransferUnitPrice())){
            zyOrderDTO.setTransferUnitPrice(MoneyUtils.fen2yuan(zyOrder.getTransferUnitPrice()));
        }
        if (Objects.nonNull(zyOrder.getRegionRangePrice())){
            zyOrderDTO.setRegionRangePrice(MoneyUtils.fen2yuan(zyOrder.getRegionRangePrice()));
        }
        if (Objects.nonNull(zyOrder.getTransferDistancePrice())){
            zyOrderDTO.setTransferDistancePrice(MoneyUtils.fen2yuan(zyOrder.getTransferDistancePrice()));
        }
        if (Objects.nonNull(zyOrder.getOrderAllPrice())){
            zyOrderDTO.setOrderAllPrice(MoneyUtils.fen2yuan(zyOrder.getOrderAllPrice()));
        }
        if (Objects.nonNull(zyOrder.getOrderPayPrice())){
            zyOrderDTO.setOrderPayPrice(MoneyUtils.fen2yuan(zyOrder.getOrderPayPrice()));
        }
        if (Objects.nonNull(zyOrder.getCouponPrice())){
            zyOrderDTO.setCouponPrice(MoneyUtils.fen2yuan(zyOrder.getCouponPrice()));
        }
        if (Objects.nonNull(zyOrder.getOrderReturnMoney())){
            zyOrderDTO.setOrderReturnMoney(MoneyUtils.fen2yuan(zyOrder.getOrderReturnMoney()));
        }

        return zyOrderDTO;
    }
}
